//app.js
import { ajax, src, util } from "utils/util.js";

App({
  onShow: function () {
    let that = this;
    wx.getSystemInfo({
      success: res => {
        console.log('手机信息res'+res.model)
        let modelmes = res.model;
        if (modelmes.search('iPhone X') != -1) {
          that.globalData.isIphoneX = true
        }

      }
    })

  },
  onLaunch: function () {
 
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        console.log(res)
        wx.setStorageSync("code", res.code)
      }
    })

    let menuButtonObject = wx.getMenuButtonBoundingClientRect();
    wx.getSystemInfo({
      success: res => {
        let statusBarHeight = res.statusBarHeight,
          navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
          navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2;//导航高度
        this.globalData.navHeight = navHeight;
        this.globalData.navTop = navTop;

        wx.setStorageSync('navHeight', navHeight)
        wx.setStorageSync('navTop', navTop)

        
        this.globalData.windowHeight = res.windowHeight;
       
      },
      fail(err) {
        console.log(err);
      }
    })
  },
  globalData: {
    userInfo: null,

    navHeight:"",
    navTop:"",
    windowHeight:""
  }
})